﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using Xinyi.Common;
using Xinyi.Data;

namespace tianweiss.admin
{
    public partial class jm_info : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            FunctionClass.CheckAdminLogin(0);

            if (!IsPostBack)
                BindData();
        }

        /// <summary>
        /// 读取数据
        /// </summary>
        private void BindData()
        {
            string strID, strSql;

            strID = Request.QueryString["ID"];
            if (!FunctionClass.CheckStr(strID, 1))
            {
                FunctionClass.ShowMsgBox("URL错误！");
                Response.End();
            }

            //打开数据库连接
            DataClass myData = new DataClass();
            SqlConnection myConn = myData.ConnOpen();

            strSql = "select * from T_JM where ID=" + strID;

            SqlDataReader myDr = myData.GetSqlDataReader(strSql, myConn);
            if (myDr.Read())
            {
                cblType.SelectedValue = myDr["TypeID"].ToString();
                cblSex.SelectedValue = myDr["Sex"].ToString();
                tbUserName.Text = myDr["UserName"].ToString();
                tbBirthday.Text = myDr["Birthday"].ToString();
                tbBirthPlace.Text = myDr["BirthPlace"].ToString();
                tbAge.Text = myDr["Age"].ToString();
                tbTel.Text = myDr["Tel"].ToString();
                tbTel1.Text = myDr["Tel1"].ToString();
                tbFax.Text = myDr["Fax"].ToString();
                tbQQ.Text = myDr["QQ"].ToString();
                tbMail.Text = myDr["Mail"].ToString();
                tbArea.Text = myDr["Area"].ToString();
                tbUserID.Text = myDr["UserID"].ToString();
                tbLinkman.Text = myDr["Linkman"].ToString();
                tbTel2.Text = myDr["Tel2"].ToString();
                tbSales.Text = myDr["Sales"].ToString();
                tbProducts.Text = myDr["Products"].ToString();
                tbStartDate.Text = myDr["StartDate"].ToString();
                tbShopGoodwill.Text = myDr["ShopGoodwill"].ToString();
                tbShopAddress.Text = myDr["ShopAddress"].ToString();
                tbAddress.Text = myDr["Address"].ToString();
                tbMemo.Text = myDr["Memo"].ToString();
                tbSuggest.Text = myDr["Suggest"].ToString();
            }
            myDr.Close();
            myDr.Dispose();

            //关闭数据库连接
            myData.ConnClose(myConn);
        }
    }
}
